package com.wangzhen.jvm.garbage;

public class ReferenceCountingDemo {

    public Object instance = null;

    private static final int _1MB = 1024*1024;
    /**
     * 这个成员属性的唯一作用就是占点内存，以便在GC日志中看清楚是否有回收过
     */
    private byte[] bigSize = new byte[2 * _1MB];

    public static void main(String[] args) {
        ReferenceCountingDemo objA = new ReferenceCountingDemo();
        ReferenceCountingDemo objB = new ReferenceCountingDemo();

        objA.instance = objB;
        objB.instance = objA;

        objA = null;
        objB = null;

        System.gc();
    }
}
